<?php

class m130727_040807_create_table_monhoc_khoihoc_baigiang_monhoc_child extends CDbMigration
{
    /*
	public function up()
	{
	}

	public function down()
	{
		echo "m130727_040807_create_table_monhoc_khoihoc_baigiang_monhoc_child does not support migration down.\n";
		return false;
	}*/

	
	// Use safeUp/safeDown to do migration with transaction
	public function safeUp()
	{
                $this->execute("
                        CREATE TABLE IF NOT EXISTS `monhoc` (
                                `id` int(11) NOT NULL AUTO_INCREMENT,
                                `name` varchar(100) CHARACTER SET utf8 NOT NULL,
                                PRIMARY KEY (`id`)
                        ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
                ");
                
                $this->execute("
                        CREATE TABLE IF NOT EXISTS `monhoc_child` (
                                `id` int(11) NOT NULL AUTO_INCREMENT,
                                `name` varchar(100) CHARACTER SET utf8 NOT NULL,
                                `monhocId` int(11) NOT NULL,
                                PRIMARY KEY (`id`)
                        ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
                ");
                
                $this->execute("
                        CREATE TABLE IF NOT EXISTS `khoihoc` (
                                `id` int(11) NOT NULL AUTO_INCREMENT,
                                `name` varchar(100) CHARACTER SET utf8 NOT NULL,
                                PRIMARY KEY (`id`)
                        ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
                ");
                
                $this->execute("
                        CREATE TABLE IF NOT EXISTS `baigiang` (
                                `id` int(11) NOT NULL AUTO_INCREMENT,
                                `name` varchar(255) CHARACTER SET utf8 NOT NULL,
                                `linkurl` varchar(255) NOT NULL,
                                `creator` int(11) NOT NULL,
                                `createdTime` timestamp NULL DEFAULT NULL,
                                `modifiedTime` timestamp NULL DEFAULT NULL,
                                `khoihocId` int(11) NOT NULL,
                                `monhocId` int(11) NOT NULL,
                                `monhocChildId` int(11) DEFAULT NULL,
                                `description` text,
                                PRIMARY KEY (`id`)
                        ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
                ");
	}

	public function safeDown()
	{
	}
	
}